<template>
	<view class="date-sec">
		<view class="d-week align-center">
			<view class="week" v-for="(item, i) in week" :key="i">{{ item }}</view>
		</view>
		<scroll-view scroll-y="true" class="d-scroll" >
			<view class="scroll-item" v-for="(ditem,di) in dateList" :key="di">
				<view class="s-title">{{ditem.monthTxt}}</view>
				<view class="s-date flex-row">
					<block  v-for="(item,i) in ditem.list" :key="i">
						<view class="date" 
						:class="[ 
							 {tips: item && item.hasTips === true},
							 {before: item && item.istoday === -1 }
						]"
						@click="tapDate(item)"
						>
							<view class="tips" v-if="item && item.hasTips">{{item.tips}}</view>
							<text class="txt">{{item && item.name ? item.name : ''}}</text>
							<view class="price clamp" v-if="item && item.name">
								<text class="mark">￥</text>
								<text class="val">{{item.price}}</text>
								
							</view>
						</view>	
					</block>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script lang="ts">
	import {
	  defineComponent,
	  watchEffect,
	  reactive,
	  toRefs,
	  // computed,
	  // watch,
	  // ref,
	  // onMounted,
	} from "vue";
	const selectTimeDate = defineComponent({
		props: {
		  dateList: {
		    type:  Array,
		    default: ()=>([]),
		  },
		},
		setup(props: any, ctx: any) {
			const data:any = reactive({
				week: ['日', '一', '二', '三', '四', '五', '六'],
				dateList:[],
			});
			watchEffect(() => {
				data.dateList = props.dateList;
			})
			// 点击选择取送车日期
			const tapDate =(item)=>{
				ctx.emit("tapDate",item);
			}
	
			return {
				...toRefs(data),
				tapDate,
			};
		}
	})
	export default selectTimeDate;
</script>

<style lang="scss" scoped>
	.date-sec{
		height: 100%;
		.d-week{
			height: 100rpx;
			background: #FFFFFF;
			.week{
				width: 186rpx;
				text-align: center;
			}
		}
		.d-scroll{
			width: 100%;
			height: calc(100% - 100rpx);
			
		}
		.scroll-item{
			padding-top: 30rpx;
			.s-title{
				padding: 0 20rpx;
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				margin-bottom: 20rpx;
			}
			.s-date{
				flex-wrap: wrap;
			}
			.date{
				width: 106rpx;
				height: 112rpx;
				
				font-size: 30rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #333333;
				line-height: 112rpx;
				text-align: center;
				position: relative;
				&.before{
					color: #9EA1B0;
				}
				.tips{
					font-size: 20rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #9EA1B0;
					position: absolute;
					top: 12rpx;
					left: 50%;
					transform: translateX(-50%);
				}
				.price{
					position: absolute;
					bottom: 6rpx;
					left: 50%;
					transform: translateX(-50%);
					max-width: 106rpx;
					min-width: 76rpx;
					// padding: 0 10rpx;
					text-align: center;
					height: 38rpx;
					font-size: 0;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
					.mark{
					    line-height: 38rpx;
						font-size: 20rpx;
					}
					.val{
						line-height: 38rpx;
						font-size: 24rpx;
					}
				}
			}
		}
	}
	
</style>